package com.wc.AlgoOJ_homework.ALgoOJ_BL5.F_砍竹子;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/4/10 19:55
 * @description http://43.138.190.70:8888/p/LQ1304?tid=66120c2c07c5c018a5dcf262
 */
public class Main {
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 200010;
    static long[] a = new long[N];
    static int n;

    public static void main(String[] args) {
        ArrayList<Long> arr = new ArrayList<>();
        n = sc.nextInt();
        for (int i = 1; i <= n; i++) a[i] = sc.nextLong();
        long res = 0;
        while (a[1] != 1){
            arr.add(a[1]);
            a[1] = (long) Math.sqrt(a[1] / 2 + 1);
        }
        res += arr.size();
        for (int i = 2; i <= n; i++) {
            ArrayList<Long> tmp = new ArrayList<>();
            while (a[i] != 1) {
                tmp.add(a[i]);
                a[i] = (long) Math.sqrt(a[i] / 2 + 1);
            }
            int sizT = tmp.size(), sizeA = arr.size();
            int idx = -1;
            for (int j = 0; j < sizT; j++) {
                long num = tmp.get(j);
                int l = 0, r = sizeA - 1;
                while (l <= r) {
                    int mid = l + r >> 1;
                    if (arr.get(mid) == num) {
                        idx = j;
                        break;
                    } else if (arr.get(mid) > num) {
                        l = mid + 1;
                    } else {
                        r = mid - 1;
                    }
                }
                if (idx != -1) break;
            }
            if (idx == -1) res += sizT;
            else res += idx;
            arr = tmp;
        }
        out.println(res);
        out.flush();
    }
}

class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
